package com.itheima.config;


import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration  // 声明配置类
@ComponentScan({"com.itheima.controller", "com.itheima.config"})  // 扫描的范围

@EnableWebMvc   // 把json 转换成字符串
public class SpringMvcConfig implements WebMvcConfigurer {

    //设置静态资源访问过滤，当前类需要设置为配置类，并被扫描加载
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //当访问/pages/????时候，从/pages目录下查找内容
        registry.addResourceHandler("/pages/**")
                .addResourceLocations("/pages/");
        registry.addResourceHandler("/html/**")
                .addResourceLocations("/html/");
        registry.addResourceHandler("/js/**")
                .addResourceLocations("/js/");
        registry.addResourceHandler("/css/**")
                .addResourceLocations("/css/");
        registry.addResourceHandler("/images/**")
                .addResourceLocations("/images/");
        registry.addResourceHandler("/plugins/**")
                .addResourceLocations("/plugins/");
        registry.addResourceHandler("/img/**")
                .addResourceLocations("/img/");
    }
}
